package com.lagou.studentsystem.servlet;

import com.lagou.studentsystem.service.StudentService;
import com.lagou.studentsystem.service.impl.StudentServiceImpl;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "RemoveStudentServlet",urlPatterns = "/removeStudent")
public class RemoveStudentServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String studentId = request.getParameter("studentId");
        StudentService studentService = new StudentServiceImpl();
        int i = studentService.removeStudentById(studentId);
        RequestDispatcher findAllStudent = request.getRequestDispatcher("findStudentAll");
        findAllStudent.forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
